﻿using Plugin.BLE.Abstractions;
using Plugin.BLE.Abstractions.Contracts;
using System.Threading.Tasks;

namespace RaceHFTools.BluetoothLE
{
    public class Product
    {
        public Device Transport;

        public string Name;
        public byte[] Id;
        public string HardwareVersion;
        public string HardwareBatch;
        public string FirmwareVersion;
        public string FirmwareNumber;
        public string BootloaderVersion;

        public bool IsConnect { get => Transport.IsConnect; }

        public Product(Controller adapter, IDevice device)
        {
            Transport = new Device(adapter, device);
        }

        ~Product()
        {

        }

        public virtual async Task PreInit()
        {
            await Transport.FindServiceAndCharacteristic();
            await Transport.UpdateMTU(Device.MTU_MAX);
            Transport.UpdateConnInterval(ConnectionInterval.High);
        }

        public async Task Disconnect()
        {
            await Transport.Disconnect();
        }
    }
}
